import os

from flask_uploads import UploadSet, configure_uploads, IMAGES, patch_request_class,AUDIO
from flask_wtf.file import FileField,FileAllowed,FileRequired
from flask_wtf import FlaskForm
from wtforms import SubmitField

from app import app


app.config['UPLOADED_PHOTOS_DEST'] = os.path.join(os.path.dirname(__file__),'static','download_data')
app.config['UPLOADED_MYFILE_ALLOW'] = AUDIO

photos = UploadSet('photos', IMAGES)

configure_uploads(app, photos)
patch_request_class(app)  # set maximum file size, default is 16MB

class UploadForm(FlaskForm):
  photo = FileField(validators=[FileAllowed(photos, '只能预测图片！'), FileRequired(u'文件未选择！')])
  submit_upload = SubmitField(u'预测')

